
var Audio = {
    isInBgPaly : false,
    playBg:function(){
        if(Config.voice != 1 || Audio.isInBgPaly){
            return
        }
        if(Config.channelID == 102 && typeof qg != "undefined"){
            if(!Audio.bgAudioContext){
                Audio.bgAudioContext = qg.createInnerAudioContext();
            }
            Audio.bgAudioContext.src =  "internal://files/lywx/"+ window.Config.fileZipDir + Config.bgm;
            Audio.bgAudioContext.loop  =  true;
            Audio.bgAudioContext.play();
        }else if(Config.channelID == 103 && hbs){
            if(!Audio.bgAudioContext){
                Audio.bgAudioContext = hbs.createInnerAudioContext();
            }
            Audio.bgAudioContext.src =  Config.strHeadResHuaWei + Config.bgm;
            Audio.bgAudioContext.loop  =  true;
            Audio.bgAudioContext.play();
        }
        else if(Config.channelID == 101){
            Laya.SoundManager.playMusic(Config.oppofileDownUrl+"res/"+Config.bgm,0);
        }else{
            Laya.SoundManager.playMusic(Config.bgm,0);
        }
        Audio.isInBgPaly = true;
    },
    stopBg:function() {
        Laya.SoundManager.stopMusic();
        Audio.isInBgPaly = false;
    },
    playVoice:function(_val,unloop){
        if(Config.voice != 1){
            return
        }
        if(typeof unloop === "undefined"){
            unloop = 0;
        }
        if(Config.channelID == 102 && typeof qg != "undefined"){
            var audioContext = qg.createInnerAudioContext()
            audioContext.src =  "internal://files/lywx/"+ window.Config.fileZipDir + _val;
            audioContext.loop  =  unloop == 0 ? true : false;
            audioContext.play();
            if(unloop == 1){
                audioContext.onEnded(function () {
                    audioContext = null;
                });
            }
        }else if(Config.channelID == 103 && hbs){
            var audioContext = hbs.createInnerAudioContext()
            audioContext.src =  Config.strHeadResHuaWei + _val;
            audioContext.loop  =  unloop == 0 ? true : false;
            audioContext.play();
            if(unloop == 1){
                audioContext.onEnded(function () {
                    audioContext = null;
                });
            }
        }
        else if(Config.channelID == 101){
            Laya.SoundManager.playSound(Config.oppofileDownUrl+"res/"+_val,unloop);
        }else{
            Laya.SoundManager.playSound(_val,unloop);
        }
    },

    /////////////////考虑到声音不需要调大小//////////////////////
    //停止所有
    pauseAll:function(){
        if(Config.channelID == 102 && typeof qg != "undefined"){
            if(Audio.bgAudioContext){
                Audio.bgAudioContext.stop()
            }
        }else if(Config.channelID == 103 && hbs){
            if(Audio.bgAudioContext){
                Audio.bgAudioContext.stop()
            }
        }else{
            //停背景音乐
            Audio.stopBg();
            //设置音效为0
            Laya.SoundManager.setSoundVolume(0);
        }
    },
    
    //恢复所有
    resumeAll:function(){
        if(Config.voice != 1){
            return
        }
        if(Config.channelID == 102 && typeof qg != "undefined"){
            if(Audio.bgAudioContext){
                Audio.bgAudioContext.play()
            }else{
                Audio.playBg();
            }
        }if(Config.channelID == 103 && hbs){
            if(Audio.bgAudioContext){
                Audio.bgAudioContext.play()
            }else{
                Audio.playBg();
            }
        }else{
            //播放背景音乐
            Audio.playBg();
            //设置音效为1
            Laya.SoundManager.setSoundVolume(1);
        }
    },

};